#include<stdio.h>
int pertimes(int number)
{
	int k=number;
	int times=0;
	while(k!=0)
	{
		int temp=k%10;
		k=k/10;
		if(temp==2)
		{
			times++;
		}
	}
	return times;
}
int main()
{
	int L,R;
	scanf("%d %d",&L,&R);
	int timestotal[100];
	int n=0;
	for(int i=L;i<=R;i++)
	{
		timestotal[n]=pertimes(i);
		n++;
	}
	int sum=0;
	for(int i=0;i<n;i++)
	{
		sum=sum+timestotal[i];
	}
	printf("%d",sum);
	return 0;
}
